'use strict';

new Vue({
  el: '#mytest',
  data: {
    tests: [],
    score: null,
    show: false,
  },
  created() {
    this.getTests();
    const user_id = $.cookie('user_id');
    if (user_id === null || user_id === '' || user_id === undefined) {
      window.location.href = 'login.html?redirect=mytest.html';
    }
  },
  methods: {
    getTests() {
      const that = this;
      $.ajax({
        url: '../getTest',
        type: 'GET',
        success(data) {
          console.log(data);
          that.tests = data;
        },
      });
    },
    getUrl(name, id) {
      return 'test.html?name=' + name + '&id=' + id;
    },
  },
});
